<!DOCTYPE html>
<html lang="en">
<head>
    <title>题目209_长度最小的子数组</title>
</head>
<body>
    <script>
        var minSubArrayLen = function(target, nums) {
            let i=0,j=0,sum=0,miniLenhth=Infinity;
            while(i<=j){ 
                if(sum<target){
                    sum+=nums[j];
                    ++j;
                }else{
                    sum-=nums[i];
                    ++i;
                }
                if(sum>=target && miniLenhth > j-i){
                    miniLenhth = j-i;
                }
            }
            return miniLenhth==Infinity? 0:miniLenhth;
        }; 

        console.log(minSubArrayLen(11,[1,1,1,1,1,1,1,1]));;
    </script>
</body>
</html>